/*
 *  Copyright (C) 2011 felixtheripper <felixtheripper_AT_gmail.com>
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package org.myorg.ctm.etk.gui.swg.util.property;

import java.io.File;
import java.util.Properties;
import org.myorg.shr.gui.swg.util.property.PrpMgrAbs;

/**
 *
 * @author felixtheripper
 *
 * email: felixtheripper_AT_gmail.com
 * ... please remove "_AT_" from the above string to get the right email address
 *
 */

public class PrpMgrEnv extends PrpMgrAbs {

    public PrpMgrEnv()	{
		super(PrpMgrEnv._STR_NAMEFILE_);
	}

    public static void s_init() throws Exception {
        if (_INSTANCE_ == null) {
                _INSTANCE_ = new PrpMgrEnv();
        }

        PrpMgrEnv._prp_ = System.getProperties();
        write();
        return;
	}

    public static void s_destroy(){
         if (_INSTANCE_ == null || PrpMgrEnv._prp_ == null){
            return;
         }
         PrpMgrEnv._prp_.clear();
         PrpMgrEnv._prp_ = null;
         _INSTANCE_ = null;
    }


    protected static void read() throws Exception
    {
	}

    protected static void write() throws Exception{
        File fleFolderVersion = PrpMgrAbs.s_getOrCreateVersionDir();
        String strPathFile =
                fleFolderVersion.toString() +
                java.io.File.separator +
                PrpMgrEnv._STR_NAMEFILE_ +
                PrpMgrAbs._STR_FILEEXT_;

        PrpMgrAbs.write(PrpMgrEnv._prp_, strPathFile);
        return;
	}

    private static PrpMgrEnv _INSTANCE_;
    final static private String _STR_NAMEFILE_ = "env";
    static private Properties _prp_ = new Properties();

}
